import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import redis.clients.jedis.Jedis;

public class JedisTester {
    private Jedis jedis;

    @BeforeEach
    public void setup() {
        //连接redis服务器，127.0.0.1:6379
        jedis = new Jedis("127.0.0.1", 6379);
        //权限认证
//        jedis.auth("foobared");
    }

    @Test
    public void testString() {
        //添加数据
        jedis.set("name", "ktjiaoyu");
        System.out.println(jedis.get("name"));

        jedis.append("name", "cakt");   //拼接
        System.out.println(jedis.get("name"));

        jedis.del("name");  //删除某个数据
        System.out.println(jedis.get("name"));

        //设置多个键值对
        jedis.mset("name", "ktjiaoyu", "age", "18", "add", "cz");
        jedis.incr("age");
        System.out.println(jedis.get("name") + "-"+ jedis.get("age") +"-"+jedis.get("add"));
    }
}
